<?php

namespace App\Models;

class Node extends Base
{
    //修改器
    public function setRouteNameAttribute($value)
    {
        $this->attributes['route_name'] = empty($value) ? '' : $value;
    }
    //获取递归数据
    public function getAllList(){
        $data = self::get()->toArray();
        return $this->treeLevel($data);
    }
    //获取多层级数据
    public function treeData($allow_node)
    {
        $query = Node::where('is_menu','1');
        if(is_array($allow_node)){
            $query->whereIn('id',array_keys($allow_node));
        }
        $menuData = $query->get()->toArray();
        return $this->subTree($menuData);
    }
}
